sgwt_show_im : Display image, with correct pixel zoom sgwt_show_im(im,range,zoom) Inputs : im - 2-d image range - 2 element vector giving display color map range, range(1) maps to black, range(2) maps to white If range not given, or empty matrix given for range, then the default is to set it to the minimum and maximum of input image. zoom - # of screen pixels taken by single image pixel. Default is 1
0001 % sgwt_show_im : Display image, with correct pixel zoom 0002 % 0003 % sgwt_show_im(im,range,zoom) 0004 % 0005 % Inputs : 0006 % im - 2-d image 0007 % range - 2 element vector giving display color map range, 0008 % range(1) maps to black, range(2) maps to white 0009 % If range not given, or empty matrix given for range, then 0010 % the default is to set it to the minimum and maximum of input image. 0011 % zoom - # of screen pixels taken by single image pixel. Default is 1 0012 0013 % This file is part of the SGWT toolbox (Spectral Graph Wavelet Transform toolbox) 0014 % Copyright (C) 2010, David K. Hammond. 0015 % 0016 % The SGWT toolbox is free software: you can redistribute it and/or modify 0017 % it under the terms of the GNU General Public License as published by 0018 % the Free Software Foundation, either version 3 of the License, or 0019 % (at your option) any later version. 0020 % 0021 % The SGWT toolbox is distributed in the hope that it will be useful, 0022 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0023 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0024 % GNU General Public License for more details. 0025 % 0026 % You should have received a copy of the GNU General Public License 0027 % along with the SGWT toolbox. If not, see <http://www.gnu.org/licenses/>. 0028 0029 function sgwt_show_im(im,range,zoom) 0030 if nargin<3 0031 zoom=1; 0032 end 0033 if ( nargin<2 || isempty(range) ) 0034 range(1)=min(im(:)); 0035 range(2)=max(im(:)); 0036 end 0037 0038 nshades=256; 0039 d_im = ( im-range(1) ) *(nshades-1) /(range(2)-range(1)); 0040 dsize=size(im)*zoom; % size in pixels to show on screen 0041 image( d_im ); 0042 colormap(gray(nshades)); 0043 0044 ax=gca; 0045 oldunits=get(ax,'Units'); 0046 set(ax,'Units','pixels'); 0047 pos = get(ax,'Position'); 0048 axis('off'); 0049 ctr = pos(1:2)+pos(3:4)/2; 0050 set(ax,'Position',[floor(ctr-dsize/2)+0.5, dsize] ); 0051 axis('equal'); 0052 0053 % restore units 0054 set(ax,'Units',oldunits);